/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.edu.sistemas.sse.entity;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.hibernate.annotations.Proxy;

/**
 *
 * @author laptop-w8
 */
@Entity
@Table(name = "TDIST")
@Proxy(lazy = false)
public class UbigeoDistrito implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "CDIST")
    private long idDistritio;
    @Column(name = "DCOD_DIST")
    private String dCodigo;
    @Column(name = "DNM_DIST")
    private String dNombre;
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "CPROV", referencedColumnName = "CPROV", nullable = false)
    private UbigeoProvincia provincia;

    public long getIdDistritio() {
        return idDistritio;
    }

    public void setIdDistritio(long idDistritio) {
        this.idDistritio = idDistritio;
    }

    public String getdCodigo() {
        return dCodigo;
    }

    public void setdCodigo(String dCodigo) {
        this.dCodigo = dCodigo;
    }

    public String getdNombre() {
        return dNombre;
    }

    public void setdNombre(String dNombre) {
        this.dNombre = dNombre;
    }

    public UbigeoProvincia getProvincia() {
        return provincia;
    }

    public void setProvincia(UbigeoProvincia provincia) {
        this.provincia = provincia;
    }
    
    public String toString(){
        return "id: "+this.dCodigo+" , nombre: "+this.dNombre;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof UbigeoDistrito) {
            UbigeoDistrito ubi = (UbigeoDistrito) obj;
            return ubi.getdCodigo().equals(this.dCodigo);
        }
        return false;
    }

}
